package legumes.server.bll;

import java.io.IOException;
import java.util.Collection;
import java.util.List;

import legumes.client.services.ToExcellException;
import legumes.shared.domain.AdminException;
import legumes.shared.domain.Customer;
import legumes.shared.domain.CustomerDTO;
import legumes.shared.domain.CustomerRole;
import legumes.shared.domain.LatLng;
import legumes.shared.domain.LoginException;
import legumes.shared.domain.MailStallParserException;
import legumes.shared.domain.NewProductMarket;
import legumes.shared.domain.Order;
import legumes.shared.domain.Product;
import legumes.shared.domain.ProductCategory;
import legumes.shared.domain.ProductVariety;
import legumes.shared.domain.SellSession;
import legumes.shared.domain.SellSessionForCustomer;
import legumes.shared.domain.Stall;
import legumes.shared.domain.Store;
import legumes.shared.domain.StoreException;
import legumes.shared.domain.UnicityViolationException;

public interface IBLLLegumesServices {

	Stall parseStallMail(String mailContent_) throws MailStallParserException;

	boolean isStoreOpened();

	void setStoreOpened(boolean b_);

	String getMessageStore();

	void setMessageStore(String message_);

	Customer getCustomer(String name_);

	List<Product> getProducts();

	List<Long> getSellSessionsDate();

	SellSession getSellSession(long date_);

	long getOpenedSellSessionId();

	/**
	 * 
	 * @param fromSellSessionId_
	 *            sell session id from which the stall is copied. No stall copy
	 *            if it is null.
	 * @return new sell session
	 */
	SellSession newSellSession(Store store_, long fromSellSessionId_);

	void save(Stall stall_);

	List<CustomerDTO> getCustomers();

	Customer addCustomer(Customer c_) throws UnicityViolationException;

	Collection<Order> getOrders(long sellSessionId_);

	/**
	 * 
	 * @param sellSessionId_
	 * @return url of report
	 * @throws IOException
	 */
	String generateOrdersReport(long sellSessionId_) throws ToExcellException;

	void setCustomerRole(String customerid_, CustomerRole role_);

	Customer getCustomer(long uuid_);

	void changePassword(CustomerDTO c_, String password_, String newPassword_)
			throws LoginException;

	void removeCustomer(CustomerDTO c_, String customerId_)
			throws AdminException, LoginException;

	Order save(CustomerDTO c_, long sellSessionId_, Order order_, boolean merge_)
			throws StoreException;

	boolean hasOrderConflict(CustomerDTO c_, long sellSessionId_, Order order_);

	SellSessionForCustomer getSellSessionForCustomer(CustomerDTO c_);

	boolean activateUserAccount(String email, String uuid);

	void init();

	void purgeSellSessions();

	Customer getCustomerFromEmail(String login_);

	void onCustomerLogon(Customer c_, String remoteHost);

	Product[] getProductsStartingWith(String prefix_);

	boolean validateNewProductMarket(NewProductMarket newProductMarket_);

	Product addNewProductMarket(NewProductMarket newProductMarket_);

	ProductCategory[] getProductCategories();

	ProductVariety[] getProductVarities();

	String resetPassword(String email_);

	List<Store> getUserStores(String userId_);

	boolean removeStore(Store store_);

	boolean isStoreNameExists(String storeName_);

	Store addStore(Store storeToAdd);

	List<Store> getStores(LatLng northEastBound_, LatLng southWestBound_);

	void save(Store store_);

}
